package lk.week02;

import commons.ListNode;

/**
 * ClassName: P0206_ReverseNodeList
 * Description:
 * Author: xyf
 * Date: 5/21/23 10:06 AM
 * Version: 1.0
 **/
public class P0206_ReverseNodeList
{
    public ListNode reverseList(ListNode head)
    {
        if (head == null)
        {
            return head;
        }

        ListNode pre = null;
        ListNode cur = pre;
        while(cur != null){
            ListNode next = cur.next;
            cur.next = pre;
            pre = cur;
            cur = next;
        }
        return pre;
    }
}